import * as echarts from 'echarts';
export default function ({
  xData = ['2019', '2020', '2021', '2022', '2023'],
  yData1 = [150, 200, 210, 220, 230],
  yData2 = [-20, 10, 20, 18, 20],
} = {}) {
  const y2max = Math.max(...yData2);
  const y2min = Math.min(...yData2);
  return {
    backgroundColor: 'transparent', //背景色
    legend: {
      left: 0,
      data: [
        {
          name: '营业收入(亿元)',
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: '#21D7FF',
            },
            {
              offset: 1,
              color: '#27BEDF',
            },
          ]),
          icon: 'roundRect',
          textStyle: {
            color: '#9DA4A6',
          },
        },
        {
          name: '增长率(%)',
          color: '#57FFAA',
          textStyle: {
            color: '#9DA4A6',
          },
        },
      ],
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow',
      },
      // formatter: function (params) {
      //   return params[0].name + '<br>' + '订单数 ：' + params[0].value;
      // },
    },
    grid: {
      left: '4%',
      right: '4%',
      bottom: '3%',
      top: '15%',
      containLabel: true,
    },
    xAxis: {
      data: xData,
      triggerEvent: true,
      axisTick: {
        show: false,
      },
      axisLine: {
        show: false,
      },
      axisLabel: {
        show: true,
        rotate: 0,
        interval: 0,
        textStyle: {
          fontSize: 14,
          color: '#9DA4A6',
        },
      },
    },
    yAxis: [
      {
        triggerEvent: true,
        splitLine: {
          show: true,
          lineStyle: {
            color: '#243F43',
          },
        },
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisLabel: {
          show: true,
          textStyle: {
            color: '#9DA4A6',
            fontSize: 14,
          },
        },
      },
      {
        type: 'value',
        min: y2min,
        max: y2max,
        splitLine: {
          show: false,
        },
        axisLabel: {
          formatter: '{value}%',
          textStyle: {
            color: '#9DA4A6',
            fontSize: 14,
          },
        },
      },
    ],
    series: [
      {
        name: '营业收入(亿元)',
        barMinHeight: 10,
        type: 'pictorialBar',
        barCategoryGap: '60%',
        symbol: 'path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z',
        itemStyle: {
          //渐变色
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: 'rgba(31, 188, 223, 1)',
            },
            {
              offset: 1,
              color: 'rgba(17, 67, 76, 0.3)',
            },
          ]),
        },
        label: {
          show: false,
          position: 'top',
          textStyle: {
            color: 'rgba(111, 87, 197, 1)',
            fontSize: 20,
          },
        },
        data: yData1,
        z: 10,
      },
      {
        name: '增长率(%)',
        type: 'line',
        smooth: true,
        showAllSymbol: true,
        symbol: 'circle',
        symbolSize: 8,
        colorBy: 'series',
        data: yData2,
        itemStyle: {
          color: '#54F6A5',
        },
      },
    ],
  };
}
